%%%%%%%%%%%%%%%%
% fit_gaussian.m
%%%%%%%%%%%%%%%%

% Data comes in as d x N matrix
% (i.e - rows are dimensions, columns are examples)
% so transpose to get as N x d
Data = Data';

[N,d] = size(Data);

Mean = mean(Data);
Full_Covar = cov(Data) ;

switch lower(Covar_Type)
  case 'spherical'
    Precision = d/(sum(diag(Full_Covar)));
    Norm = (Precision/(2*pi))^(d/2);
  case 'diagonal'
    Precision = 1./(diag(Full_Covar));
    Norm = (prod(Precision)/(2*pi))^(d/2);
  case 'full'
    Precision = inv(Full_Covar);
    Norm = sqrt(det(Precision))/(2*pi)^(d/2);
  otherwise
    disp(sprintf('Unknown covariance type %s', Covar_Type));
    exit(1);
end
